fix(isMobilePhone): restrict mk-MK locale to valid mobile numbers only#2579
fix(isMobilePhone): restrict mk-MK locale to valid mobile numbers only#2579tech-and-avinash wants to merge 11 commits into
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
could you fix the failed tests as well |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2579 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2535 2535
Branches 641 641
=========================================
Hits 2535 2535 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the Macedonian (mk-MK) mobile phone number validation to only accept valid mobile numbers, excluding landlines and service numbers. The regex is simplified to match only mobile prefixes (07x for national format and +3897x for international format).
- Simplified the mk-MK regex pattern to match only mobile number prefixes
- Updated test cases to reflect the new validation rules
- Moved test case position in the test file for better organization
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/lib/isMobilePhone.js |
Updated regex pattern to restrict mk-MK validation to mobile numbers only |
test/validators.test.js |
Replaced existing mk-MK test cases with new valid/invalid examples matching the updated validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| 'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/, | ||
| 'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/, | ||
| 'mk-MK': /^(\+?389|0)?((?:2[2-9]\d{6}|(?:3[1-4]|4[2-8])\d{6}|500\d{5}|5[2-9]\d{6}|7[0-9][2-9]\d{5}|8[1-9]\d{6}|800\d{5}|8009\d{4}))$/, | ||
| 'mk-MK': /^(\+3897[0-9]|07[0-9])[0-9]{6}$/, |
There was a problem hiding this comment.
The regex pattern is too restrictive. It only matches numbers with exactly 8 digits after the prefix, but the test cases show '+38971234567' (9 digits after +389) and '071234567' (8 digits total including prefix). The pattern should be /^(+3897[0-9]\d{6}|07[0-9]\d{6})$/ to match the expected formats.
| 'mk-MK': /^(\+3897[0-9]|07[0-9])[0-9]{6}$/, | |
| 'mk-MK': /^(\+3897[0-9]\d{6}|07[0-9]\d{6})$/, |
Updated the regex for the mk-MK locale to match only valid Macedonian mobile phone numbers.
This excludes landlines (e.g., 02, 03x), toll-free/service numbers (e.g., 800), and other invalid formats.
Supports both national (07x) and international (+3897x) mobile formats.
Includes tests for valid and invalid examples.